

/*
 * Serial communication
 */

#define LED_PIN LED_BUILTIN
int val;
bool LEDIsOn = false;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  val = Serial.read();
  if(val==-1)return;
  Serial.println((char)val);
  if(val == 'R')
  {
    digitalWrite(LED_PIN, LOW);
    delay(200);
    digitalWrite(LED_PIN, HIGH);
    delay(2000);
    Serial.println("Hello world!");
  }

}
